package Collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectiontionDemo {
    public static void main(String[] args) {
        Collection c1=new ArrayList();
        c1.add("66");
        c1.add("77");
        c1.add("88");
        System.out.println("c1:"+c1);

        Collection c2=new ArrayList();
        c2.add("11");
        c2.add("22");
        c2.add("33");
        System.out.println("c2:"+c2);

        c1.addAll(c2);
        System.out.println("c1:"+c1);
        System.out.println("c2:"+c2);

        boolean contains=c1.containsAll(c2);
        System.out.println("是否包含:"+contains);
        /*
        //取交集：c1中仅保留与c2所共有的元素，而c2不变
        c1.retainAll(c2);
        System.out.println("c1:"+c2);
        System.out.println("c2:"+c2);

         */

        //删交集：将c1中与c2共有的元素删除,c2不变
        c1.removeAll(c2);
        System.out.println("c1:"+c1);
        System.out.println("c2:"+c2);
    }
}
